import React, { Component } from 'react';
import PropTypes, { object } from 'prop-types';
import DemoChild2 from './Child2'
class DomeChild1 extends Component {
    // static PropTypes = { 
    //     role:PropTypes.string.isRequired
    //  } 
    render() { 
        // console.log(this);
        const {role,userinfo}=this.props
        return (
        <div className='child1'>
            用户名1（数据来自于父组件）
            {
                role==='admin'?(<div>
                    {Object.keys(userinfo).map(i=>{
                        return (<div key={i}>
                            {i}-{userinfo[i]}
                        </div>)
                    })}
                </div>):'没有权限'
            }
            <DemoChild2  username={this.props.username}/>
        </div>
        );
    }
}
 
export default DomeChild1;